<template>
	<view class="" style="height: 100%;">
		<!-- <mescroll-uni :fixed="false" @init="mescrollInit" :height="height" :down="downOption"
			@down="downCallback" :up="upOption" @up="upCallback" @emptyclick="emptyClick"> -->
		<view class="mescroll-item" >
			<view class="mescroll-item-hader">
				<view class="mescroll-item-hader-img">
					<image :src="info.goodsImg" mode=""></image>
				</view>
				<view class="mescroll-item-hader-right">
					<view class="mescroll-item-hader-right-item">
						<view class="right-item-text">
							{{info.goodsName}}
						</view>
						<view class="right-item-sumber">
							X{{info.quantity}}
						</view>
					</view>
					<view class="mescroll-item-hader-right-item" style="margin-top: 15px;">
						<view class="right-item-text-text">
							兑换盟友：{{info.userName}}（{{phoneSubstring(info.userPhone)}}）
						</view>
						<view class="right-item-sumber">
						
						</view>
					</view>
					<view class="mescroll-item-hader-right-item" style="margin-top: 4px;">
						<view class="right-item-text-text">
							申请时间：{{info.createDate}}
						</view>
						<view class="right-item-sumber">
						
						</view>
					</view>
					<view class="mescroll-item-hader-right-item" style="margin-top: 4px;">
						<view class="right-item-text-text">
							
						</view>
						<view class="right-item-jifen">
							<image src="/static/img/index/ic_jifen.png" mode=""></image>
							<text class="amt">{{number.parsePrice(info.consumptionPoints)}}积分</text>
						</view>
					</view>
				</view>
				
			</view>
			
		</view>
		<view class="mescroll-fooer">
			<view class="ygdz">
				<view class="ygdz-left">
					邮寄地址
				</view>
				<view class="ygdz-right">
					复制
				</view>
			</view>
			<view class="adder-xiangxi">
			{{info.userName}}  {{info.userPhone}}
			</view>
			<view class="adder-xiangxi">
			{{info.mailingAddress || ''}}
			</view>
			<view class="ygdz">
				<view class="ygdz-left">
					SN号（0台）
				</view>
				<view class="">
					
				</view>
			</view>
		</view>
		
		<!-- </mescroll-uni> -->
	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	const api = require('../../../config/api');
	const util = require('../../../utils/util');
	import number from "../../../utils/number.js";
	export default {
		mixins: [MescrollMixin], // 使用mixin
		data() {
			return {
				number: number, //声明number属性并赋值为引入的number模块
				downOption: {
					auto: true //  false 不自动加载 (mixin已处理第一个tab触发downCallback)  true
				},
				upOption: {
					auto: false, // 不自动加载
					noMoreSize: 4,
					textLoading: '加载中 ...', // 加载中的提示文本
					textNoMore: '暂无更多', // 没有更多数据的提示文本
					empty: {
						tip: '暂无相关数据', // 提示
					},
				},
				goods: [
				],
				goodsId:'',
				info:{}
			}
		},
		onLoad(o) {
			this.goodsId = o.id
			this.getexchangeRecordDetail();
		},
		onShow() {
		
		},
		methods: {
			phoneSubstring(str){
				return util.phoneSubstringfct(str)
			},
			/*下拉刷新的回调 */
			downCallback() {
				// 这里加载你想下拉刷新的数据, 比如刷新轮播数据
				// loadSwiper();
				// 下拉刷新的回调,默认重置上拉加载列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
				this.mescroll.resetUpScroll()
			},
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				//联网加载数据
				// this.mescroll.endErr();
				let pageNum = page.num; // 页码, 默认从1开始
				let pageSize = page.size; // 页长, 默认每页10条
				const res = util.request(
					api.exchangeRecordUrl , {
						page: pageNum,
						limit: pageSize,
						type:'1'
					},
					'POST'
				).then(res => {
					console.log(res);
					//联网成功的回调,隐藏下拉刷新和上拉加载的状态;
					let totalPage = res.data.pages;
					this.mescroll.endByPage(res.data.records.length, totalPage); //必传参数(当前页的数据个数, 总页数)
					// this.mescroll.endSuccess(res.data.records.length);
					//设置列表数据
					if (page.num == 1) this.goods = []; //如果是第一页需手动制空列表
					this.goods = this.goods.concat(res.data.records); //追加新数据
				}).catch(() => {
					//联网失败, 结束加载
					this.mescroll.endErr();
				})
			},
			async getexchangeRecordDetail() {
				const res = await util.request(
					api.exchangeRecordDetailUrl + '/' + this.goodsId, {},
					'POST'
				);
				console.log(res);
				if (res.code !== 0) {
					uni.showToast({
						title: res.msg,
						icon: "none"
					})
			
				} else {
					this.info = res.data
				}
			},
		}
		}
</script>

<style>
	page {
		height: 100%;
	/* 	background-color: #F5F1F0; */
	}

	.mescroll-upwarp {
		min-height: 0rpx !important;
	}
</style>
<style lang="scss" scoped>
	.mescroll-item{
		background-color: #fff;
		// width: 100%;
		margin-left: 10px;
		
		// margin: 5px 0;
		padding: 10px;
		font-size: 14px;
		border-bottom: 1px solid #E6E6E6 ;
	}
	.mescroll-fooer{
		background-color: #fff;
		// width: 100%;
		margin-left: 10px;
		
		// margin: 5px 0;
		padding: 10px;
		font-size: 14px;
	}
	.mescroll-item-hader{
		display: flex;
		align-items: center;
		justify-content: space-between;
		
	}
	.mescroll-item-hader-img{
		width: 80px;
		height: 80px;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.mescroll-item-hader-right{
		flex: 1;
		margin-left: 14px;
		// display: flex;
		// align-items: center;
		// justify-content: space-between;
	}
	.mescroll-item-hader-right-item{
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	.right-item-text{
		font-size: 16px;
		font-weight: 600;
		color: #000;
	}
	.right-item-sumber{
		font-size: 14px;
		color: #7B7B7B;
	}
	.right-item-text-text{
		font-size: 11px;
		color: #7B7B7B;
	}
	.amt{
		color: #FF6868;
	}
	.mescroll-item-time{
		margin-top: 5px;
		color: #929292;
	}
	.right-item-jifen{
		display: flex;
		align-items: center;
		font-size: 15px;
		font-weight: 600;
		image{
			width: 15px;
			height: 15px;
		}
	}
	.ygdz{
		margin-top: 11px;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	.ygdz-left{
		font-size: 16px;
		font-weight: 600;
		color: #000;
	}
	.ygdz-right{
		padding: 5px 20px;
		font-size: 13px;
		color: #6A9FFB;
		border-radius: 5px;
		border: 1px solid #6A9FFB;
	}
	.adder-xiangxi{
		margin-top: 7px;
		font-size: 13px;
		color: #7B7B7B;
	}
</style>